# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gst-plugins-good

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}0.10"
pkgver=0.10.31
pkgrel=1
pkgdesc="GStreamer Multimedia Framework Base Plugins (mingw-w64)"
arch=('any')
url="http://gstreamer.freedesktop.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
    "${MINGW_PACKAGE_PREFIX}-pkg-config"
    "${MINGW_PACKAGE_PREFIX}-gstreamer0.10"
    "gtk-doc"
    "${MINGW_PACKAGE_PREFIX}-python2"
    "${MINGW_PACKAGE_PREFIX}-speex"
    )
depends=(
    "${MINGW_PACKAGE_PREFIX}-cairo"
    "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
    "${MINGW_PACKAGE_PREFIX}-gst-plugins-base0.10"
    "${MINGW_PACKAGE_PREFIX}-libcaca"
    "${MINGW_PACKAGE_PREFIX}-libsoup"
    "${MINGW_PACKAGE_PREFIX}-libvpx"
    "${MINGW_PACKAGE_PREFIX}-taglib"
    "${MINGW_PACKAGE_PREFIX}-wavpack"
    )
options=(!libtool strip staticlibs)
source=(${url}/src/${_realname}/${_realname}-${pkgver}.tar.xz
    test-rtp-payloading.patch
    mingw64-gst-plugins-good-waveform-git.patch
    0001-fix-X-detection.mingw.patch
    0002-fix-test-running.mingw.patch)
md5sums=('555845ceab722e517040bab57f9ace95'
         '6781763eb752d57f3d111a41905d25bd'
         '86fbe1b55536e71bdb0474e6e41f83c8'
         '89b320a3a5d5585801eef1b8e0489483'
         '2416482a6ee486dd4d00acd90f4d7e86')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  sed -i '/AC_PATH_XTRA/d' configure.ac
  sed -i 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/' configure.ac
  patch -Np1 -i ${srcdir}/test-rtp-payloading.patch
  patch -Np0 -i ${srcdir}/mingw64-gst-plugins-good-waveform-git.patch
  patch -p1 -i ${srcdir}/0001-fix-X-detection.mingw.patch
  patch -p1 -i ${srcdir}/0002-fix-test-running.mingw.patch
  
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --disable-static \
    --enable-shared \
    --enable-silent-rules \
    --enable-experimental \
    --disable-gtk-doc
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  rm -f ${pkgdir}${MINGW_PREFIX}/lib/gstreamer-*/*.a
}
